home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16855 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  46 lines

  1. Path: lyra.csx.cam.ac.uk!news
  2. From: gdr11@cl.cam.ac.uk (Gareth Rees)
  3. Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.edu
  4. Subject: Re: ANSI C and POSIX (was Re: C/C++ knocks the crap out of Ada)
  5. Followup-To: comp.lang.c
  6. Date: 12 Apr 1996 12:26:26 +0100
  7. Organization: Cambridge University Computer Lab
  8. Message-ID: <yxsag0hel99.fsf@stint.cl.cam.ac.uk>
  9. References: <JSA.96Feb16135027@organon.com> <4kb2j8$an0@solutions.solon.com>
  10.     <4kbrt5$k3h@mulga.cs.mu.OZ.AU> <dewar.829012486@schonberg>
  11.     <4kcpgkINNcku@keats.ugrad.cs.ubc.ca>
  12.     <TYNOR.96Apr9105114@twratl.atlanta.twr.com>
  13.     <4kgunm$o4o@gde.GDEsystems.COM>
  14. NNTP-Posting-Host: stint.cl.cam.ac.uk
  15. In-reply-to: Chet's message of 10 Apr 1996 18:30:14 GMT
  16. X-Newsreader: Gnus v5.0.15
  17.  
  18. Chet <kackman> wrote:
  19. > If i = j depends on your unit of address. If i is assumed a longword then
  20. >      &i + 4 = &j is true
  21. >      not 
  22. >      &i + 1 = &j
  23.  
  24. In the C language, the `unit of address' in address arithmetic depends
  25. on the type of the address on which the arithmetic happens.  Go back and
  26. read section 5.4 of K&R2 again.
  27.  
  28. $ uname -sr
  29. SunOS 4.1.3_U1
  30. $ cat arith.c
  31. #include <stdio.h>
  32. int main () {
  33.     int i;
  34.     printf("%p + 1 = %p\n", &i, &i+1);
  35.     return 0;
  36. }
  37. $ gcc arith.c
  38. $ ./a.out
  39. f7fffa3c + 1 = f7fffa40
  40.  
  41. Followups to comp.lang.c only.
  42.  
  43. -- 
  44. Gareth Rees
  45.